package top.kaoshanji.ch04.employee;

import java.time.LocalDate;

/**
 * 员工
 * author kaoshanji
 * ^_^
 * create time 2024/11/24 20:42
 */
public class Employee {

    // 实例字段的修饰符都是 private。。就只能被自身内部方法访问
    private String name;

    // 薪水
    private double salary;

    // 入职日期
    private LocalDate hireDay;

    // 构造器
    // 调用构造器时传入这些参数，为实例字段赋值，就可以提供给其他方法操作了
    public Employee(String n, double s, int year, int month, int day) {
        name = n;
        salary = s;
        hireDay = LocalDate.of(year, month, day);
    }

    // 这些是提供给外部访问的
    public String getName() {
        return name;
    }

    public double getSalary() {
        return salary;
    }

    public LocalDate getHireDay() {
        return hireDay;
    }

    // 只有对象里这个方法才能修改 salary
    public void raiseSalary(double byPercent) {
        double raise = salary * byPercent / 100;
        salary += raise;
    }

}
